home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / javax / management / MBeanAttributeInfo.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  4.0 KB  |  148 lines

  1. package javax.management;
  2.  
  3. import com.sun.jmx.mbeanserver.GetPropertyAction;
  4. import com.sun.jmx.mbeanserver.Introspector;
  5. import java.lang.reflect.Method;
  6. import java.security.AccessController;
  7.  
  8. public class MBeanAttributeInfo extends MBeanFeatureInfo implements Cloneable {
  9.    private static final long serialVersionUID;
  10.    static final MBeanAttributeInfo[] NO_ATTRIBUTES;
  11.    private final String attributeType;
  12.    private final boolean isWrite;
  13.    private final boolean isRead;
  14.    // $FF: renamed from: is boolean
  15.    private final boolean field_0;
  16.  
  17.    public MBeanAttributeInfo(String var1, String var2, String var3, boolean var4, boolean var5, boolean var6) {
  18.       this(var1, var2, var3, var4, var5, var6, (Descriptor)null);
  19.    }
  20.  
  21.    public MBeanAttributeInfo(String var1, String var2, String var3, boolean var4, boolean var5, boolean var6, Descriptor var7) {
  22.       super(var1, var3, var7);
  23.       this.attributeType = var2;
  24.       this.isRead = var4;
  25.       this.isWrite = var5;
  26.       if (var6 && !var4) {
  27.          throw new IllegalArgumentException("Cannot have an \"is\" getter for a non-readable attribute");
  28.       } else if (var6 && !var2.equals("java.lang.Boolean") && !var2.equals("boolean")) {
  29.          throw new IllegalArgumentException("Cannot have an \"is\" getter for a non-boolean attribute");
  30.       } else {
  31.          this.field_0 = var6;
  32.       }
  33.    }
  34.  
  35.    public MBeanAttributeInfo(String var1, String var2, Method var3, Method var4) throws IntrospectionException {
  36.       this(var1, attributeType(var3, var4), var2, var3 != null, var4 != null, isIs(var3), ImmutableDescriptor.union(Introspector.descriptorForElement(var3), Introspector.descriptorForElement(var4)));
  37.    }
  38.  
  39.    public Object clone() {
  40.       try {
  41.          return super.clone();
  42.       } catch (CloneNotSupportedException var2) {
  43.          return null;
  44.       }
  45.    }
  46.  
  47.    public String getType() {
  48.       return this.attributeType;
  49.    }
  50.  
  51.    public boolean isReadable() {
  52.       return this.isRead;
  53.    }
  54.  
  55.    public boolean isWritable() {
  56.       return this.isWrite;
  57.    }
  58.  
  59.    public boolean isIs() {
  60.       return this.field_0;
  61.    }
  62.  
  63.    public String toString() {
  64.       String var1;
  65.       if (this.isReadable()) {
  66.          if (this.isWritable()) {
  67.             var1 = "read/write";
  68.          } else {
  69.             var1 = "read-only";
  70.          }
  71.       } else if (this.isWritable()) {
  72.          var1 = "write-only";
  73.       } else {
  74.          var1 = "no-access";
  75.       }
  76.  
  77.       return this.getClass().getName() + "[" + "description=" + this.getDescription() + ", " + "name=" + this.getName() + ", " + "type=" + this.getType() + ", " + var1 + ", " + (this.isIs() ? "isIs, " : "") + "descriptor=" + this.getDescriptor() + "]";
  78.    }
  79.  
  80.    public boolean equals(Object var1) {
  81.       if (var1 == this) {
  82.          return true;
  83.       } else if (!(var1 instanceof MBeanAttributeInfo)) {
  84.          return false;
  85.       } else {
  86.          MBeanAttributeInfo var2 = (MBeanAttributeInfo)var1;
  87.          return var2.getName().equals(this.getName()) && var2.getType().equals(this.getType()) && var2.getDescription().equals(this.getDescription()) && var2.getDescriptor().equals(this.getDescriptor()) && var2.isReadable() == this.isReadable() && var2.isWritable() == this.isWritable() && var2.isIs() == this.isIs();
  88.       }
  89.    }
  90.  
  91.    public int hashCode() {
  92.       return this.getName().hashCode() ^ this.getType().hashCode();
  93.    }
  94.  
  95.    private static boolean isIs(Method var0) {
  96.       return var0 != null && var0.getName().startsWith("is") && (var0.getReturnType().equals(Boolean.TYPE) || var0.getReturnType().equals(Boolean.class));
  97.    }
  98.  
  99.    private static String attributeType(Method var0, Method var1) throws IntrospectionException {
  100.       Class var2 = null;
  101.       if (var0 != null) {
  102.          if (var0.getParameterTypes().length != 0) {
  103.             throw new IntrospectionException("bad getter arg count");
  104.          }
  105.  
  106.          var2 = var0.getReturnType();
  107.          if (var2 == Void.TYPE) {
  108.             throw new IntrospectionException("getter " + var0.getName() + " returns void");
  109.          }
  110.       }
  111.  
  112.       if (var1 != null) {
  113.          Class[] var3 = var1.getParameterTypes();
  114.          if (var3.length != 1) {
  115.             throw new IntrospectionException("bad setter arg count");
  116.          }
  117.  
  118.          if (var2 == null) {
  119.             var2 = var3[0];
  120.          } else if (var2 != var3[0]) {
  121.             throw new IntrospectionException("type mismatch between getter and setter");
  122.          }
  123.       }
  124.  
  125.       if (var2 == null) {
  126.          throw new IntrospectionException("getter and setter cannot both be null");
  127.       } else {
  128.          return var2.getName();
  129.       }
  130.    }
  131.  
  132.    static {
  133.       long var0 = 8644704819898565848L;
  134.  
  135.       try {
  136.          GetPropertyAction var2 = new GetPropertyAction("jmx.serial.form");
  137.          String var3 = (String)AccessController.doPrivileged(var2);
  138.          if ("1.0".equals(var3)) {
  139.             var0 = 7043855487133450673L;
  140.          }
  141.       } catch (Exception var4) {
  142.       }
  143.  
  144.       serialVersionUID = var0;
  145.       NO_ATTRIBUTES = new MBeanAttributeInfo[0];
  146.    }
  147. }
  148.